import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsNumber, IsOptional, IsString } from 'class-validator';
import { Transform } from 'class-transformer';

export enum VideoStatusEnum {
  PENDING = 'pending',
  APPROVED = 'approved',
  REJECTED = 'rejected',
  HIDDEN = 'hidden',
  MANUALREVIEW = 'manualReview'
}

export class QueryVideosDto {
  @ApiProperty({ description: '页码', required: false, default: 1 })
  @IsOptional()
  @IsNumber()
  @Transform(({ value }) => parseInt(value, 10))
  pageNum?: number = 1;

  @ApiProperty({ description: '每页数量', required: false, default: 10 })
  @IsOptional()
  @IsNumber()
  @Transform(({ value }) => parseInt(value, 10))
  pageSize?: number = 10;

  @ApiProperty({ description: '视频ID', required: false })
  @IsOptional()
  @IsNumber()
  @Transform(({ value }) => value ? parseInt(value, 10) : undefined)
  videoId?: number;

  @ApiProperty({ description: '用户ID', required: false })
  @IsOptional()
  @IsNumber()
  @Transform(({ value }) => value ? parseInt(value, 10) : undefined)
  userId?: number;

  @ApiProperty({ description: '用户名称', required: false })
  @IsOptional()
  @IsString()
  username?: string;

  @ApiProperty({ description: '视频标题', required: false })
  @IsOptional()
  @IsString()
  title?: string;

  @ApiProperty({ 
    description: '视频状态', 
    required: false,
    enum: VideoStatusEnum
  })
  @IsOptional()
  @IsEnum(VideoStatusEnum)
  status?: VideoStatusEnum;

  @ApiProperty({ description: '分类名称', required: false })
  @IsOptional()
  @IsString()
  categoryName?: string;
}